package com.ivr.cm.dao.impl;

import org.apache.log4j.Logger;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

import com.ivr.cm.dao.IUserHangDao;
import com.ivr.cm.service.BaseServiceIF;
import com.ivr.cm.util.BaseUtil;
import com.ivr.cm.vo.UserHangVo;

/**
 * 挂机记录数据实现
 * @author liugeng
 * @date 2015-12-15
 * @version 1.0
 *
 */
public class UserHangDaoImpl extends JdbcDaoSupport implements IUserHangDao, BaseServiceIF<Object> {
	private static Logger logger = Logger.getLogger(UserHangDaoImpl.class);
	@Override
	public int doProcess(Object obj) {
		if(obj instanceof UserHangVo){
			return insertUserHang((UserHangVo)obj);
		}
		return 0;
	}
	/**保存挂机记录数据*/
	@Override
	public int insertUserHang(UserHangVo userHangVo) {
		String sql = "insert into tb_ivr_user_hang(mobile,sp_number,linkId) values(?,?,?)";
		Object[] param = new Object[]{userHangVo.getMobile(),userHangVo.getSp_number(),userHangVo.getLinkId()};
		logger.info(String.format("[%s][%s]保存挂机记录数据[%s]", userHangVo.getMobile(),userHangVo.getSp_number(), BaseUtil.logSQL(sql, param)));
		int count = this.getJdbcTemplate().update(sql, param);
		return count;
	}
}
